#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
//http://www.codechef.com/problems/NOTATRI
int GetWayNumNotATriangle(int num, vector<int> vector);
bool	IsThreeNumATriangle(int num1, int num2, int num3);

int main()
{
    int inputNum = 1;
    vector<int> numArray;
	while(inputNum != 0)
	{
		cin>>inputNum;
		for (int i = 0; i < inputNum; ++ i)
		{
			int stickValue;
			cin>>stickValue;
			numArray.push_back(stickValue);
		}
		if (inputNum != 0)
		{
			cout<<GetWayNumNotATriangle(inputNum, numArray)<<endl;
			numArray.clear();
		}
	}
	//int inputNum = 1;
	//vector<int> outputNum;
	//vector<int> numArray;
	//while(inputNum != 0)
	//{
	//	cin>>inputNum;
	//	for (int i = 0; i < inputNum; ++ i)
	//	{
	//		int stickValue;
	//		cin>>stickValue;
	//		numArray.push_back(stickValue);
	//	}
	//	if (inputNum != 0)
	//	{
	//		outputNum.push_back(GetWayNumNotATriangle(inputNum, numArray));
	//		numArray.clear();
	//	}
	//}
	//for (vector<int>::iterator iter = outputNum.begin(); iter != outputNum.end(); ++ iter)
	//{
	//	cout<<*iter<<endl;
	//}
	/*int array1[] = {4, 2, 10};
	int inputLength1;
	cin>>inputLength1;
	for (int i = 0; i < inputLength1; ++ i)
	{
		int temp;
		cin>>temp;
		array1[i] = temp;
	}
	
	int array2[] = {1, 2, 3};
	int inputLength2;
	cin>>inputLength2;
	for (int i = 0; i < inputLength2; ++ i)
	{
		int temp;
		cin>>temp;
		array2[i] = temp;
	}

	int array3[] = {5, 2, 9, 6};
	int inputLength3;
	cin>>inputLength3;
	for (int i = 0; i < inputLength3; ++ i)
	{
		int temp;
		cin>>temp;
		array3[i] = temp;
	}

	int isFinal = 1;
	while(isFinal!= 0)
	{
		cin>>isFinal;
	}

	if (isFinal == 0)
	{
		int num1 = GetWayNumNotATriangle(sizeof(array1)/sizeof(array1[0]), array1);
		cout << num1 <<endl;
		int num2 = GetWayNumNotATriangle(sizeof(array2)/sizeof(array2[0]), array2);
		cout << num2 <<endl;
		int num3 = GetWayNumNotATriangle(sizeof(array3)/sizeof(array3[0]), array3);
		cout << num3 <<endl;
	}*/
	
	system("pause");
	return 0;
}

bool	IsThreeNumNotATriangle(int num1, int num2, int num3)
{
	if (num1 + num2 >= num3 && num1 + num3 >= num2 && num2 + num3 >= num1)
	{
		return false;
	}
	else
	{
		return true;
	}
}

int GetWayNumNotATriangle(int num, vector<int> vector)
{
	int count = 0;
	for (int i = 0; i < num - 2; ++ i)
	{
		int firstNum = vector[i];
		for (int j = i + 1; j < num - 1; ++ j)
		{
			int secondNum = vector[j];
			for (int k = j + 1; k < num; ++ k)
			{
				int thirdNum = vector[k];
				if (IsThreeNumNotATriangle(firstNum, secondNum, thirdNum))
				{
					count ++;
				}
			}
		}
	}
	return count;
}